#！ /usr/bin/python3
# coding=UTF-8

from urllib import request

if __name__ == '__main__':
    url = 'http://www.csdn.net'  # csdn 不修改user agent 是无法访问的
    head = {}
    head['User-Agent'] = 'Mozilla/5.0 (Android5.1.1) AppleWebKit/537. 36 (KHTML, like Gecko) Chrome/41. 0.2225.0 Safari/537. 36'
    req = request.Request(url, headers=head)
    # f = request.urlopen(req)
    f = request.urlopen(url)
    html = f.read().decode('utf-8')
    print(html)